function ngdomSpriteEnemy(x, y) {
	if (!ngdom.Engine) return;
	ngdomSpriteEnemy.prototype.base.constructor.call(this, x, y);
	this.type = 'enemy';
	this.cssClass = 'enemy';
	this.attackDelay = 400; //delay between attacks
	this.attackTurnDelay = 200; //delay while turning to face player
	this.aimDelay = 300; //delay at start of attack for ranged weapons
	this.weapon = new ngdomSpriteWeapon(this);
	this.canDrop = true;
	
	if (typeof(x) == 'object') $.extend(true, this, x);
	
	console.assert(this.position.x > 10 && this.position.x < 310 && this.position.y > 10 && this.position.y < 230);
}
ngdomSpriteEnemy.inherits(ngdomSprite);
ngdomSpriteEnemy.prototype.wallAtPosition = function (position, walls) {
	if (typeof(position) == 'undefined') position = this.position;
	if (position.x < 1 || position.x > this.engine.portalSize.width - 1 || 
		position.y < 1 || position.y > this.engine.portalSize.height - 1)
		return 1;
	return ngdomSpriteEnemy.prototype.base.wallAtPosition.call(this, position, walls);
};
ngdomSpriteEnemy.prototype.behave = function () {
	ngdomSpriteEnemy.prototype.base.behave.call(this);
	if (this.dead || this.dying || this.wounded) return;

	if (!this.attacking && this.engine.tickCount - this.attackStartTime > this.attackLength + this.attackDelay)
	{
		if (this.engine.player.position.x > this.position.x - 10 && this.engine.player.position.x < this.position.x + 10)
		{
			if (this.engine.player.position.y > this.position.y) this.attackDirection = 3;
			else this.attackDirection = 1;
			this.attack();
		}
		if (this.engine.player.position.y > this.position.y - 10 && this.engine.player.position.y < this.position.y + 10)
		{
			if (this.engine.player.position.x > this.position.x) this.attackDirection = 2;
			else this.attackDirection = 4;
			this.attack();
		}
	}
};
ngdomSpriteEnemy.prototype.save = function () {
	return { wxp: this.worthXP };
};
ngdomSpriteEnemy.prototype.load = function (data) {
	this.worthXP = data.wxp;
};